package club.xcgame520.okhttp;

import android.content.Context;
import android.util.Log;

/**
 * 下载文件请求回调
 * <br/>
 * Created by 小灿 on 2016/11/14.
 */
public class DownloadResponseCallback {

    private Context context;
    private String url;

    public Context getContext() {
        return context;
    }

    public String getUrl() {
        return url;
    }

    public void onStart() {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件下载开始：" + url);
        }
    }

    public void onFailure(int statusCode) {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件下载失败" + statusCode);
        }
    }

    public void onSuccess(String filePath) {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件下载成功：" + filePath);
        }
    }

    public void onCancel() {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件下载取消：" + url);
        }
    }

    public void onFinish() {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件下载结束：" + url);
        }
    }

    public void onProgress(int progress) {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件下载进度：" + progress);
        }
    }

    protected void setUrl(String url) {
        this.url = url;
    }

    protected void setContext(Context context) {
        this.context = context;
    }

}
